<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>登录</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../layer/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="../layer/css/login.css" media="all" />
</head>
<body >
<div class="login">
    <h1>微信公众号管家</h1>
    <form class="layui-form" id="weirdor" v-cloak>
        <div class="layui-form-item">
            <input class="layui-input" name="username" placeholder="用户名" lay-verify="required" type="text" v-model="username" autocomplete="off">
        </div>
        <div class="layui-form-item">
            <input class="layui-input" name="password" placeholder="密码" lay-verify="required" type="password" v-model="password" @keyup.enter="login" autocomplete="off">
        </div>
        <div class="layui-form-item form_code">
            <input class="layui-input" id="verify" name="verify" placeholder="验证码" lay-verify="required" type="text" autocomplete="off">
            <div class="code"><img src="/sys/verify" width="116" height="36" onclick="this.src=('/sys/verify?reload='+(new Date()).getTime())"></div>
        </div>
        <button class="layui-btn login_btn"  type="button" @click="login" >登录</button>
    </form>
</div>
<script type="text/javascript" src="../layer/layui/layui.js"></script>
<script src="libs/jquery.min.js"></script>
<script src="plugins/jqgrid/jquery.jqGrid.min.js"></script>
<script src="libs/vue.min.js"></script>
<script src="libs/bootstrap.min.js"></script>
<script src="libs/app.js"></script>
<script src="js/common.js"></script>
<script type="text/javascript">
    layui.use('layer', function() { //独立版的layer无需执行这一句
        var $ = layui.jquery, layer = layui.layer; //独立版的layer无需执行这一句
    });
    var vm = new Vue({
        el:'#weirdor',
        data:{
            username: '',
            password: '',
            error: false,
            errorMsg: ''
        },
        beforeCreate: function(){
            if(self != top){
                top.location.href = self.location.href;
            }
        },
        methods: {
            login: function () {
                var verify=$("#verify").val();
                var data = "username="+vm.username+"&password="+vm.password+"&verify="+verify;
                $.ajax({
                    type: "POST",
                    url: baseURL + "sys/login",
                    data: data,
                    dataType: "json",
                    success: function(r){
                        if(r.code == 0){//登录成功
                            localStorage.setItem("token", r.token);
                            parent.location.href ='index.html';
                        }else{
                            layer.msg(r.msg);
                        }
                    }
                });
            }
        }
    });
</script>
</body>
</html>